package com.kly.springbootinit.model.vo;

import com.kly.springbootinit.model.entity.Vehicle;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 车辆管理视图
 *
 * @author <a href="https://github.com/likly">程序员鹿七</a>
 * @from <a href="https://www.code-nav.cn">编程导航学习圈</a>
 */
@Data
public class VehicleVO implements Serializable {

    /**
     * 车辆ID
     */
    private Long id;

    /**
     * 车型
     */
    private String model;

    /**
     * 车牌号
     */
    private String licensePlate;

    /**
     * 状态（0-可租，1-已租，2-维护中）
     */
    private Integer status;

    /**
     * 日租金
     */
    private BigDecimal dailyRate;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 图片url
     */
    private String imgUrl;


    private static final long serialVersionUID = 1L;

    /**
     * 封装类转对象
     *
     * @param vehicleVO
     * @return
     */
    public static Vehicle voToObj(VehicleVO vehicleVO) {
        if (vehicleVO == null) {
            return null;
        }
        Vehicle vehicle = new Vehicle();
        BeanUtils.copyProperties(vehicleVO, vehicle);
        return vehicle;
    }

    /**
     * 对象转封装类
     *
     * @param vehicle
     * @return
     */
    public static VehicleVO objToVo(Vehicle vehicle) {
        if (vehicle == null) {
            return null;
        }
        VehicleVO vehicleVO = new VehicleVO();
        BeanUtils.copyProperties(vehicle, vehicleVO);
        return vehicleVO;
    }
}
